<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        var num = parseInt(prompt("请输入一个正整数"))

        var count = 0;
        for (var i = 1; i <= num; i++) {
            if (num % i == 0) {
                count += 1
            }

        }
        if (count > 2) {
            alert(num + "不是质数")
        } else if (num == 1) {
            alert("质数定义为在大于1的自然数中,除了1和它自身外,不能整除其他自然数的数叫做质数;否则称为合数。")
        }else {
            alert(num + "是质数")
        }
    </script>
</head>

<body>
</body>

</html>